{% extends 'base.html' %}
{% block title %}
    标签类型列表
{% endblock %}
{% block css %}

{% endblock %}
{% block page-title %}
    标签类型列表
{% endblock %}
{% block page-content %}
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">标签类型列表</h3>
                </div>
                <div class="panel-body">
                    {% if messages %}
                        {% for message in messages %}
                            <div class="alert alert-{{ message.tags }} alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                {{ message }}
                            </div>
                        {% endfor %}
                    {% endif %}
                    <div class="row" style="margin-bottom: 5px">
                        {% if perms.cmdb.add_type %}
                        <div class="col-md-1"><a href="{% url 'cmdb:type-add' %}" class="btn btn-primary">添加标签类型</a></div>
                        {% endif %}
                        <div class="col-md-2" style="float: right">
                            <form class="form-horizontal" role="form">
                                    <div class="input-group">
                                        <input type="text" id="keyword" name="keyword" class="form-control"  value="{{ keyword|default_if_none:'' }}" placeholder="关键字">
                                        <span class="input-group-btn">
                                        <button type="submit" class="btn btn-effect-ripple btn-primary">搜索</button>
                                        </span>
                                    </div>

                            </form>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th>类型名称</th>
                                        <th>中文名称</th>
                                        <th>创建时间</th>
                                        {% if perms.cmdb.change_type or perms.cmdb.delete_type %}
                                        <th>动作</th>
                                        {% endif %}
                                    </tr>
                                </thead>
                                <tbody>
                                  {% for type in page_obj.object_list %}
                                    <tr>
                                        <td>{{ type.name }}</td>
                                        <td>{{ type.name_cn }}</td>
                                        <td>{{ type.create_time }}</td>
                                        {% if perms.cmdb.change_type or perms.cmdb.delete_type %}
                                        <td>
                                            {% if perms.cmdb.change_type %}
                                                <a href="{% url 'cmdb:type-edit' type.id %}" class="btn btn-primary btn-xs">编辑</a>
                                            {% endif %}
                                            {% if perms.cmdb.delete_type %}
                                                <a href="{% url 'cmdb:type-delete' type.id %}" class="btn btn-danger btn-xs">删除</a>
                                            {% endif %}
                                        </td>
                                        {% endif %}
                                    </tr>
                                    {% endfor %}
                                </tbody>
                            </table>

                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-4">
                           <p style="margin-top: 10px"> 显示 [{{ page_obj.paginator.count }}] 条数据中的 第 [{{ page_obj.start_index }}] 至 [{{ page_obj.end_index }}] 的数据</p>
                        </div>
                        <div class="col-md-8">
                             {% if page_obj.paginator.num_pages > 1 %}
                                {% include '_paginator.html' %}
                             {% endif %}
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
{% endblock %}
{% block js %}
    <script>
        $('.taggit').addClass('active');
        $('.taggit .tag_type').addClass('active');
    </script>
{% endblock %}